const goodsModel = require("../models/student_model");



function getcart(goods, onRetGot, onErrGot) {
    console.log("c",goods);
    goodsModel.selectcart(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}
function getall(goods, onRetGot, onErrGot) {
    console.log("c",goods);
    goodsModel.selectall(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}
function getlegend(goods, onRetGot, onErrGot) {
    console.log("c",goods);
    goodsModel.legend(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}
function getlist(goods, onRetGot, onErrGot) {
    goodsModel.list(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}




function addcart(goods, onRetGot, onErrGot) {
    console.log("goods2",goods);
    goodsModel.addcart(goods,(ret)=>onRetGot({ret,code:200}),(err)=>onErrGot({err,code:400}))
}

function deletecart(goods, onRetGot, onErrGot) {
    goodsModel.deletecart(goods, (ret) => onRetGot({ret,code:200}), (err) => onErrGot({ err ,code:400}));
    
}

function updatecart(goods, onRetGot, onErrGot) {
    console.log(goods);
    goodsModel.updatecart(goods, (ret) => onRetGot({ret,code:200}), (err) => onErrGot({ err ,code:400}));
    
}


const userController = {
    getcart,
    deletecart,
    addcart,
    updatecart,
    getlist,
    getall,
    getlegend
};
module.exports = userController;